import React from 'react';
import { BrowserRouter, Route, NavLink, withRouter, Redirect, Switch} from 'react-router-dom'
import 'animate.css'
import './App.css';


import {AppRouter} from './router'
import Login from './views/Login';

class App extends React.Component {
    routerCheck(shouldLogin,com) {
        if (shouldLogin) {
            return <Redirect to='/login'></Redirect>;
        } else {
            return com
        }
    }
    render() {
        return (
            <BrowserRouter>
                <audio id='playTag'></audio>
                <Switch>
                    {
                        AppRouter.map(item => {

                            return <Route key={item.path} path={item.path} exact={item.exact} render={this.routerCheck.bind(this, item.shouldLogin,<item.component />)}></Route>
                        })
                    }
                </Switch>
            </BrowserRouter>
        );
    }
}

export default App;
